//var token = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ7XCJ1c2VySWRcIjo3NyxcInVzZXJuYW1lXCI6XCIxNTgxMTU2MTE3M1wiLFwicGFzc3dvcmRcIjpcIjQxRDJGNjk4NzQyMzg0NkI3ODc2RDE4ODUwNTY4OEZFXCIsXCJ0aE9wZW5pZFwiOm51bGwsXCJtb2JpbGVcIjpudWxsLFwic3VuZ29JZFwiOm51bGwsXCJuaWNrbmFtZVwiOm51bGwsXCJoZWFkUG9ydHJhaXRcIjpudWxsLFwiYWRkVGltZVwiOm51bGwsXCJiaXJ0aGRheVwiOm51bGwsXCJzZXhcIjpudWxsLFwiaGVpZ2h0XCI6bnVsbCxcIndlaWdodFwiOm51bGwsXCJzbW9rZVwiOm51bGwsXCJkcmlua1wiOm51bGwsXCJlYXRIb2JieVwiOm51bGwsXCJqb2JUeXBlXCI6bnVsbCxcImxhYmVsXCI6bnVsbCxcImFwcFZlcnNpb25zXCI6bnVsbCxcIm9yZ0lkXCI6bnVsbH0iLCJleHAiOjE1Mjg5NTk4MzB9.HvRzBM0wCnu35fI1HZ57BwKhuTn2nN9PEvGGvYBAYt4';
// fnWeb('2018-05-16','77','77',token);
function fnSpirit(addTime, userId, friendId, token) { //初始化
	spiritDate(addTime, userId, friendId, token);
}
//接口
function spiritDate(addTime, userId, friendId, token) { //精神
	var url = "http://api.sungohealth.com/spirit/data";
	var data = {
		addTime: addTime,
		userId: userId,
		friendId: friendId,
		token: token
	};
	$.ajax({
		type: "POST",
		url: url,
		data: data,
		dataType: "json",
		success: function(data, status, xhr) {
			console.log(data);
			if(data.status == '0' || data.msg == '成功') {
				$('.unEmpty').removeClass('dn');
				$('.empty').addClass('dn');
				fn_option(addTime, data.data); //数据渲染
			} else {
				$('.unEmpty').addClass('dn');
				$('.empty').removeClass('dn');
			}
		},
		error: function(result) {
			console.log(result);
		}
	});
}

//接口测试数据
//var dataTemp = {
//  "status": 0,
//  "msg": "成功",
//  "data": {
//      "hrId": 342,
//      "userId": 77,
//      "dataDate": "2018-05-16",
//      "ecgRhythm": null,
//      "tensionDegree": "4",
//      "ecgPressure": "5",
//      "tiredIndex": "4.5",
//      "psychosisCode": "精神压力较低，疲劳指数适中，身心负荷较高。您的副交感神经主导，会感到慵懒、忧郁、四肢无力、提不起兴趣等症状。",
//      "updateTime": "16:42:14",
//      "eyTensionDegree": "56",
//      "eyHrPressure": "9",
//      "eyTiredIndex": "48",
//      "addTime": "16:42:13",
//      "averageEcgs": [
//          {
//              "day_tension_degree": "44",
//              "data_date": "2018-05-16",
//              "day_tired_index": "35",
//              "day_hr_pressure": "9",
//              "average_ecg_id": 131
//          },
//          {
//              "day_tension_degree": "51",
//              "data_date": "2018-05-15",
//              "day_tired_index": "41",
//              "day_hr_pressure": "17",
//              "average_ecg_id": 107
//          },
//          {
//              "day_tension_degree": "56",
//              "data_date": "2018-05-14",
//              "day_tired_index": "46",
//              "day_hr_pressure": "30",
//              "average_ecg_id": 98
//          },
//          {
//              "day_tension_degree": "34",
//              "data_date": "2018-05-12",
//              "day_tired_index": "18",
//              "day_hr_pressure": "41",
//              "average_ecg_id": 82
//          },
//          {
//              "day_tension_degree": "36",
//              "data_date": "2018-05-11",
//              "day_tired_index": "26",
//              "day_hr_pressure": "27",
//              "average_ecg_id": 69
//          },
//          {
//              "day_tension_degree": "50",
//              "data_date": "2018-05-10",
//              "day_tired_index": "46",
//              "day_hr_pressure": "15",
//              "average_ecg_id": 57
//          },
//          {
//              "data_date": "2018-05-09",
//              "average_ecg_id": 52
//          },
//          {
//              "data_date": "2018-05-08",
//              "average_ecg_id": 34
//          },
//          {
//              "day_tension_degree": "42",
//              "data_date": "2018-05-07",
//              "day_tired_index": "29",
//              "day_hr_pressure": "9",
//              "average_ecg_id": 29
//          },
//          {
//              "data_date": "2018-04-22",
//              "average_ecg_id": 81
//          }
//      ],
//      "hr": {
//          "hrId": 173,
//          "hrData": "[{\"09:23:01\":\"86\"},{\"09:33:37\":\"97\"},{\"09:43:37\":\"88\"},{\"09:53:38\":\"85\"},{\"10:03:38\":\"79\"},{\"10:13:38\":\"89\"},{\"10:23:38\":\"98\"},{\"10:33:38\":\"96\"},{\"11:02:59\":\"86\"},{\"13:47:25\":\"103\"},{\"13:57:25\":\"93\"},{\"14:07:59\":\"98\"},{\"14:17:59\":\"89\"},{\"14:27:59\":\"85\"},{\"14:37:59\":\"93\"},{\"14:47:59\":\"104\"},{\"15:17:59\":\"106\"},{\"15:27:59\":\"84\"},{\"16:07:00\":\"87\"},{\"16:17:00\":\"93\"},{\"16:27:00\":\"80\"}]",
//          "sleepHrTime": "{}",
//          "userId": 77,
//          "dataDate": "2018-05-16",
//          "hrSleep": null,
//          "hrDay": "91",
//          "hrNight": null,
//          "addTime": 1526433962000,
//          "score": null,
//          "status": "processed"
//      },
//      "hrs": [
//          {
//              "score": "13",
//              "data_date": "2018-05-12",
//              "hr_id": 116
//          },
//          {
//              "score": "33",
//              "data_date": "2018-05-11",
//              "hr_id": 98
//          },
//          {
//              "score": "4",
//              "data_date": "2018-05-10",
//              "hr_id": 83
//          },
//          {
//              "score": "",
//              "data_date": "2018-05-09",
//              "hr_id": 78
//          },
//          {
//              "score": "4",
//              "data_date": "2018-05-08",
//              "hr_id": 71
//          },
//          {
//              "score": "3",
//              "data_date": "2018-04-22",
//              "hr_id": 115
//          }
//      ],
//      "ecgDay": [
//          {
//              "hrId": 342,
//              "userId": 77,
//              "dataDate": "2018-05-16",
//              "ecgRhythm": null,
//              "tensionDegree": "4",
//              "ecgPressure": "5",
//              "tiredIndex": "4.5",
//              "psychosisCode": "精神压力较低，疲劳指数适中，身心负荷较高。您的副交感神经主导，会感到慵懒、忧郁、四肢无力、提不起兴趣等症状。",
//              "updateTime": "16:42:14",
//              "eyTensionDegree": "56",
//              "eyHrPressure": "9",
//              "eyTiredIndex": "48",
//              "addTime": "16:42:13"
//          },
//          {
//              "hrId": 328,
//              "userId": 77,
//              "dataDate": "2018-05-16",
//              "ecgRhythm": null,
//              "tensionDegree": "4",
//              "ecgPressure": "5",
//              "tiredIndex": "4.5",
//              "psychosisCode": "精神压力较低，疲劳指数较低，身心负荷适中。您的副交感神经主导，会感到慵懒、忧郁、四肢无力、提不起兴趣等症状。",
//              "updateTime": "16:42:14",
//              "eyTensionDegree": "33",
//              "eyHrPressure": "9",
//              "eyTiredIndex": "23",
//              "addTime": "13:41:13"
//          }
//      ]
//  }
//};
//fn_option('2018-05-16',dataTemp.data);


function fn_option(time, data) {
//	 $('.unEmpty').removeClass('dn');$('.empty').addClass('dn');

	//页面展示信息
	//评星
	star_sun('.spirit_star0', data.ecgRhythm); //精神节律
	star_sun('.spirit_star1', data.tensionDegree); //身心负荷
	star_sun('.spirit_star2', data.ecgPressure); //精神压力
	star_sun('.spirit_star3', data.tiredIndex); //疲劳指数

	$(".olState li").html(data.psychosisCode); //精神状态提示

	//精神状态
	if(data.eyTensionDegree) {
		$(".spirit0_1").html(data.eyTensionDegree);
	} //身心负荷
	if(data.eyHrPressure) {
		$(".spirit0_2").html(data.eyHrPressure);
	} //精神压力
	if(data.eyTiredIndex) {
		$(".spirit0_3").html(data.eyTiredIndex);
	} //疲劳指数

	//昼夜节律
	if(data.hr) {
		if(data.hr.hrSleep) {
			$(".spirit1_1").html(data.hr.hrSleep);
		} //睡眠基准心率
		if(data.hr.hrDay) {
			$(".spirit1_2").html(data.hr.hrDay);
		} //日间平均心率
		if(data.hr.hrNight) {
			$(".spirit1_3").html(data.hr.hrNight);
		} //昼夜心率差
	}
	var useHourTemp = ['0:00', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '3:00', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '6:00', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '9:00', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '12:00', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '15:00', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '18:00', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '21:00', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '24:00'];

	if(data.hr) {
		var hr_data = JSON.parse(data.hr.hrData);
	}
	var ten_minute = [];
	for(var m = 0; m < 145; m++) {
		ten_minute[m] = m * 10;
	}
	var spirit1_data1 = []; //数值
	var spirit1_data1_text = []; //心率文字
	var spirit1_data1_txt = []; //描述
	if(hr_data) {
		$.each(hr_data, function(key, val) {
			$.each(val, function(k, v) {
				var minutesTemp = Math.floor(k.split(':')[0] * 60) + Math.floor(k.split(':')[1]);
				$.each(ten_minute, function(m, n) {
					if(Math.abs(minutesTemp - n) <= 5) { //小于等于5
						spirit1_data1[m] = v;
						spirit1_data1_text[m] = v;
						spirit1_data1_txt[m] = k;
					}
				})
			})
		});
		if(spirit1_data1.length < 145) {
			spirit1_data1[144] = '';
		} //数组不足145个时
		if(spirit1_data1_txt.length < 145) {
			spirit1_data1_txt[144] = '';
		}

		if(spirit1_data1_text.length < 145) {
			spirit1_data1_text[144] = '';
		}

	}

	// console.log(spirit1_data1);
	/*if(spirit1_data1){//补缺失1位的不足
	    $.each(spirit1_data1, function(key, val) {//心率
	        if(!val && spirit1_data1[key-1] && spirit1_data1[key+1]){
	            spirit1_data1[key] = (parseInt(spirit1_data1[key-1])+parseInt(spirit1_data1[key+1]))/2
	        }
	    });
	}*/
	if(spirit1_data1) { //补缺失2位以及以下的不足
		$.each(spirit1_data1, function(key, val) { //心率
			if(!val && spirit1_data1[key - 1] && spirit1_data1[key + 1]) { //缺一位
				spirit1_data1[key] = (parseInt(spirit1_data1[key - 1]) + parseInt(spirit1_data1[key + 1])) / 2
			} else if(!val && spirit1_data1[key - 1] && spirit1_data1[key + 2]) { //缺两位
				spirit1_data1[key] = (parseInt(spirit1_data1[key - 1]) + parseInt(spirit1_data1[key + 2])) / 2;
				spirit1_data1[key + 1] = (parseInt(spirit1_data1[key - 1]) + parseInt(spirit1_data1[key + 2])) / 2;
			}
		});
	}

	var start1, start2, end1, end2, s1Temp, s2Temp, e1Temp, e2Temp,
		pieces_txt = [{
				lte: 1,
				color: '#86d9e0'
			},
			{
				gt: 1,
				lte: 3,
				color: '#86d9e0'
			},
			{
				gt: 2,
				color: '#86d9e0'
			}
		];
	if(data.hr) {
		if(JSON.parse(data.hr.sleepHrTime).sleepStart1 && JSON.parse(data.hr.sleepHrTime).sleepStart2) {
			console.log(1);
			start1 = JSON.parse(data.hr.sleepHrTime).sleepStart1.split(':');
			start2 = JSON.parse(data.hr.sleepHrTime).sleepStart2.split(':');
			end1 = JSON.parse(data.hr.sleepHrTime).sleepEnd1.split(':');
			end2 = JSON.parse(data.hr.sleepHrTime).sleepEnd2.split(':');
			s1Temp = Math.round((Math.floor(start1[0] * 60) + Math.floor(start1[1])) / 10);
			s2Temp = Math.round((Math.floor(start2[0] * 60) + Math.floor(start2[1])) / 10);
			e1Temp = Math.round((Math.floor(end1[0] * 60) + Math.floor(end1[1])) / 10);
			e2Temp = Math.round((Math.floor(end2[0] * 60) + Math.floor(end2[1])) / 10);
			pieces_txt = [{
					lte: s1Temp,
					color: '#86d9e0'
				},
				{
					gt: s1Temp,
					lte: e1Temp,
					color: '#0091ea'
				},
				{
					gt: e1Temp,
					lte: s2Temp,
					color: '#86d9e0'
				},
				{
					gt: s2Temp,
					lte: e2Temp,
					color: '#0091ea'
				},
				{
					gt: e2Temp,
					color: '#86d9e0'
				}
			];

		} else if(JSON.parse(data.hr.sleepHrTime).sleepStart1) {
			start1 = JSON.parse(data.hr.sleepHrTime).sleepStart1.split(':');
			end1 = JSON.parse(data.hr.sleepHrTime).sleepEnd1.split(':');
			s1Temp = Math.round((Math.floor(start1[0] * 60) + Math.floor(start1[1])) / 10);
			e1Temp = Math.round((Math.floor(end1[0] * 60) + Math.floor(end1[1])) / 10);
			pieces_txt = [{
					lte: s1Temp,
					color: '#86d9e0'
				},
				{
					gt: s1Temp,
					lte: e1Temp,
					color: '#0091ea'
				},
				{
					gt: e1Temp,
					color: '#86d9e0'
				}
			];
		} else if(JSON.parse(data.hr.sleepHrTime).sleepStart2) {
			console.log(3);
			start2 = JSON.parse(data.hr.sleepHrTime).sleepStart2.split(':');
			end2 = JSON.parse(data.hr.sleepHrTime).sleepEnd2.split(':');
			s2Temp = Math.round((Math.floor(start2[0] * 60) + Math.floor(start2[1])) / 10);
			e2Temp = Math.round((Math.floor(end2[0] * 60) + Math.floor(end2[1])) / 10);
			pieces_txt = [{
					lte: s2Temp,
					color: '#86d9e0'
				},
				{
					gt: s2Temp,
					lte: e2Temp,
					color: '#0091ea'
				},
				{
					gt: e2Temp,
					color: '#86d9e0'
				}
			];
		}
	}

	//数据处理
	var last16 = dayList(time).last16; //日期
	var dataTemp = dayList(time).ecShow; //echart日期
	var uesTemp = dayList(time).ecUse; //echart日期下标

	//精神-数据
	var spirit_data1 = [],
		spirit_data2 = [],
		spirit_data3 = [],
		spirit2_data1 = [];
	var data_arr0 = data.averageEcgs;
	var data_arr1 = data.hrs;
	var data_arr2 = data.ecgDay;
	var menu3 = '';

	$.each(last16, function(key, val) { //日期数据比对，生成echart需要数据
		if(data_arr0) {
			$.each(data_arr0, function(k, v) {
				if(val == v.data_date) { //精神状态趋势分析
					spirit_data1[key] = v.day_tension_degree; //身心负荷
					spirit_data2[key] = v.day_hr_pressure; //精神压力
					spirit_data3[key] = v.day_tired_index; //疲劳指数
				}
			});
		}
		if(data_arr1) {
			$.each(data_arr1, function(k, v) { //昼夜节律趋势分析
				if(val == v.data_date) {
					spirit2_data1[key] = v.score;
				}
			});
		}

	});
	if(data_arr2) {
		$.each(data_arr2, function(key, val) {

			var sxfh = '';
			var jsyl = '';
			var plzs = '';
			var cssj = '';

			//测试时间
			if(val.eyTensionDegree) {
				cssj = val.addTime;
//				console.info(cssj);
			} else {
				cssj = '';
			}
			//身心负荷
			if(val.eyTensionDegree) {
				sxfh = val.eyTensionDegree;
			} else {
				sxfh = '--';
			}
			//精神压力
			if(val.eyHrPressure) {
				jsyl = val.eyHrPressure;
			} else {
				jsyl = '--';
			}
			//疲劳指数
			if(val.eyTiredIndex) {
				plzs = val.eyTiredIndex;
				//				console.info(plzs);
			} else {
				plzs = '--';
			}
			menu3 += '<div class="swiper-slide" style="width:100%">' +
				'<div><b class="organs0_6">' + cssj + '</b></div>' +
				'<ul class="wordage2 comBox mb24">' +
				'<li class="comFlex">' +
				'<h2>身心负荷</h2>' +
				'<h3 class="spirit0_1">' + sxfh + '</h3>' +
				'</li>' + '<li class="comFlex">' +
				'<h2>精神压力</h2>' +
				'<h3 class="spirit0_2">' + jsyl + '</h3>' +
				' </li>' +
				'<li class = "comFlex" > ' +
				'<h2> 疲劳指数 </h2>' +
				'<h3 class = "spirit0_3" > ' + plzs + ' </h3>' +
				'</li>' +
				'</ul>' +
				'</div>';
		});
	} else {
		menu3 += '<div class="swiper-slide" style="width:100%">' +
			'<div><b class="organs0_6"></b></div>' +
			'<ul class="wordage2 comBox mb24">' +
			'<li class="comFlex">' +
			'<h2>身心负荷</h2>' +
			'<h3 class="spirit0_1">---</h3>' +
			'</li>' + '<li class="comFlex">' +
			'<h2>精神压力</h2>' +
			'<h3 class="spirit0_2">---</h3>' +
			' </li>' +
			'<li class = "comFlex" > ' +
			'<h2> 疲劳指数 </h2>' +
			'<h3 class = "spirit0_3" >---</h3>' +
			'</li>' +
			'</ul>' +
			'</div>';
	}
//	console.log(menu3);
	$(".hs").html(menu3);
	var kk = 0;
	var mySwiper = new Swiper('.hei', { //渲染执行
		pagination: '.pagination',
		// loop:true,
		loop: false,
		grabCursor: true,
		paginationClickable: true,
		onSlideChangeEnd: function(swiper) {
			kk = swiper.activeIndex;
			//alert(swiper.activeIndex);
			// swiper.activeIndex 这个就是索引， 从 0 开始！ 可看一共有多少元素！

			//获取swiper的index重新加载
			if(data_arr0) { //获取不同的呼吸率/静息心率/心脏功能
				$(".olState li").html(data_arr0[kk].visceraCode); //运动状态提示
				if(data_arr0[kk].heartRate) {
					$(".organs0_1").html(data_arr0[kk].heartRate);
				} //呼吸率
				if(data_arr0[kk].restingRate) {
					$(".organs0_2").html(data_arr0[kk].restingRate);
				} //静息心率
				if(data_arr0[kk].cardiacFunc) {
					$(".organs0_3").html(data_arr0[kk].cardiacFunc);
				} //心脏功能
			}

		},
	});
	$('.arrow-left3').on('click', function(e) {
		e.preventDefault();
		mySwiper.swipePrev();
	});
	$('.arrow-right3').on('click', function(e) {
		e.preventDefault();
		mySwiper.swipeNext();
	});

	if(spirit_data1.length < 16) {
		spirit_data1[15] = '';
	} //数组不足16个时
	if(spirit_data2.length < 16) {
		spirit_data2[15] = '';
	}
	if(spirit_data3.length < 16) {
		spirit_data3[15] = '';
	}
	if(spirit2_data1.length < 16) {
		spirit2_data1[15] = '';
	}

	// 精神0
	var option0 = {
		grid: {
			y: 50,
			x2: 14,
			y2: 30,
			x: 40
		},
		tooltip: {
			trigger: 'axis',
			showDelay: 0,
			hideDelay: 0,
			transitionDuration: 0,
			backgroundColor: '#fff',
			borderColor: '#999',
			borderWidth: 1,
			borderRadius: 4,
			textStyle: {
				color: '#666'
			},
			axisPointer: {
				type: 'line',
				lineStyle: {
					color: '#fd7a51',
					width: 2,
					type: 'solid'
				}
			},
			position: function(p) {
				if(p[0] > 200) {
					return [p[0] - 110, 28];
				} else {
					return [p[0], 28];
				}
			},
			formatter: function(params) { //自定义内容
				var timeTemp = dataTemp[params[0].dataIndex].split('/');
				var timeShow = timeTemp[0] + '月' + timeTemp[1] + '日';
				var res = '<div class="tooltip"><p>' + timeShow + '</p>';
				for(var i = 0; i < params.length; i++) {
					if(i == 0) {
						if(params[i].data) {
							res += '<p class="p_fd"><b></b>身心负荷 ' + params[i].data + '</p>'
						} else {
							res += '<p class="p_fd"><b></b>身心负荷 ---</p>'
						}
					} else if(i == 1) {
						if(params[i].data) {
							res += '<p class="p_00">精神压力 ' + params[i].data + '</p>'
						} else {
							res += '<p class="p_00">精神压力 ---</p>'
						}
					} else if(i == 2) {
						if(params[i].data) {
							res += '<p class="p_86">疲劳程度 ' + params[i].data + '</p>'
						} else {
							res += '<p class="p_86">疲劳程度 ---</p>'
						}
					}
				}
				res += '</div>';
				return res;
			},
		},
		color: ['#fd7b52', '#0091ea', '#86d9e0'], //图例颜色
		legend: { //图例
			x: 'left',
			padding: [0, 0, 0, 35],
			itemWidth: 15,
			itemHeight: 6,
			itemGap: 27,
			data: [{
					name: '身心负荷',
					icon: 'rect',
				},
				{
					name: '精神压力',
					icon: 'rect'
				},
				{
					name: '疲劳指数',
					icon: 'rect'
				}
			],
		},
		xAxis: {
			type: 'category',
			boundaryGap: true,
			data: uesTemp, //日期下标数据
			axisLabel: {
				interval: 0,
				textStyle: {
					color: '#999'
				}
			},
			axisLine: {
				lineStyle: {
					color: 'e7e5e4',
				}
			},
			axisTick: {
				show: false
			},
			splitArea: {
				show: false,
			}
		},
		yAxis: {
			scale: true,
			max: 100,
			min: 0,
			splitNumber: 5,
			type: 'value',
			axisLabel: {
				show: true,
				textStyle: {
					color: '#999'
				}
			},
			splitLine: {
				show: true,
				lineStyle: {
					type: 'dotted'
				}
			},
			axisLine: {
				show: false
			},
			axisTick: {
				show: false
			},
		},
		series: [{
			name: '身心负荷',
			type: 'line',
			smooth: true,
			data: spirit_data1, //精神数据1
			itemStyle: {
				normal: {
					lineStyle: {
						color: '#fd7b52'
					}
				}
			},
		}, {
			name: '精神压力',
			type: 'line',
			smooth: true,
			data: spirit_data2, //精神数据2
			itemStyle: {
				normal: {
					lineStyle: {
						color: '#0091ea'
					}
				}
			},
		}, {
			name: '疲劳指数',
			type: 'line',
			smooth: true,
			data: spirit_data3, //精神数据3
			itemStyle: {
				normal: {
					lineStyle: {
						color: '#86d9e0'
					}
				}
			},
		}, ],
	};

	//精神1
	var option1 = {
		grid: {
			y: 20,
			x2: 14,
			y2: 30,
			x: 40,
		},
		tooltip: {
			trigger: 'axis',
			showDelay: 0,
			hideDelay: 0,
			transitionDuration: 0,
			backgroundColor: '#fff',
			borderColor: '#999',
			borderWidth: 1,
			borderRadius: 4,
			textStyle: {
				color: '#666'
			},
			axisPointer: {
				type: 'line',
				lineStyle: {
					color: '#fd7a51',
					width: 2,
					type: 'solid'
				},
			},
			position: function(p) {
				if(p[0] > 200) {
					return [p[0] - 60, 28];
				} else {
					return [p[0], 28];
				}
			},
			formatter: function(params) { //自定义内容
				var timeTemp = spirit1_data1_txt[params[0].dataIndex];
				var timeTemp_txt = spirit1_data1_text[params[0].dataIndex];
				if(!timeTemp) {
					timeTemp = '--:--:--'
				}
				var res = '<div class="tooltip"><p>' + timeTemp + '</p>'
				for(var i = 0; i < params.length; i++) {
					if(i == 0) {
						if(timeTemp_txt) {
							res += '<p>' + timeTemp_txt + 'bpm</p>'
						} else {
							res += '<p>---bpm</p>'
						}
					}
				}
				res += '</div>';
				return res;
			},
		},
		xAxis: {
			type: 'category',
			boundaryGap: false,
			data: useHourTemp, //时间下标数据
			axisLabel: {
				interval: 17,
				textStyle: {
					color: '#999',
					fontSize: '9'
				}
			}, //每隔17下标一次
			axisLine: {
				lineStyle: {
					color: 'e7e5e4',
				}
			},
			axisTick: {
				show: false
			},
			splitArea: {
				show: false,
			}
		},
		yAxis: {
			scale: true,
			max: 160,
			min: 0,
			interval: 40,
			type: 'value',
			axisLabel: {
				show: true,
				textStyle: {
					color: '#999'
				}
			},
			splitLine: {
				show: true,
				lineStyle: {
					type: 'dotted'
				}
			},
			axisLine: {
				show: false
			},
			axisTick: {
				show: false
			},
		},
		visualMap: { //时间分布
			show: false,
			dimension: 0,
			pieces: pieces_txt,
		},
		series: [{
			type: 'line',
			smooth: true,
			symbol: 'null',
			symbolSize: 0,
			data: spirit1_data1,
			itemStyle: {
				normal: {
					lineStyle: {
						width: 2
					}
				}
			},
		}], //精神数据4
	};

	//精神2
	var option2 = {
		grid: {
			y: 20,
			x2: 14,
			y2: 30,
			x: 40,
		},
		tooltip: {
			trigger: 'axis',
			showDelay: 0,
			hideDelay: 0,
			transitionDuration: 0,
			backgroundColor: '#fff',
			borderColor: '#999',
			borderWidth: 1,
			borderRadius: 4,
			textStyle: {
				color: '#666'
			},
			axisPointer: {
				type: 'line',
				lineStyle: {
					color: '#fd7a51',
					width: 2,
					type: 'solid'
				},
			},
			position: function(p) {
				if(p[0] > 200) {
					return [p[0] - 60, 28];
				} else {
					return [p[0], 28];
				}
			},
			formatter: function(params) { //自定义内容
				var timeTemp = dataTemp[params[0].dataIndex].split('/');
				var timeShow = timeTemp[0] + '月' + timeTemp[1] + '日';

				var res = '<div class="tooltip"><p>' + timeShow + '</p>';
				for(var i = 0; i < params.length; i++) {
					if(i == 0) {
						if(params[i].data) {
							res += '<p>' + params[i].data + 'bpm</p>'
						} else {
							res += '<p>---bpm</p>'
						}
					}
				}
				res += '</div>';
				return res;
			},
		},
		xAxis: {
			type: 'category',
			boundaryGap: true,
			data: uesTemp, //日期下标数据
			axisLabel: {
				interval: 0,
				textStyle: {
					color: '#999'
				}
			},
			axisLine: {
				lineStyle: {
					color: 'e7e5e4',
				}
			},
			axisTick: {
				show: false
			},
			splitArea: {
				show: false,
			}
		},
		yAxis: {
			scale: true,
			max: 50,
			min: 0,
			splitNumber: 5,
			type: 'value',
			axisLabel: {
				show: true,
				textStyle: {
					color: '#999'
				}
			},
			splitLine: {
				show: true,
				lineStyle: {
					type: 'dotted'
				}
			},
			axisLine: {
				show: false
			},
			axisTick: {
				show: false
			},
		},
		series: [{
			type: 'line',
			smooth: true,
			data: spirit2_data1, //精神数据5
			itemStyle: {
				normal: {
					color: '#86d9e0',
					lineStyle: {
						color: '#86d9e0'
					}
				}
			},
		}],
	};

	echarts.init(document.getElementById("spirit0")).setOption(option0, true);
	echarts.init(document.getElementById("spirit1")).setOption(option1, true);
	echarts.init(document.getElementById("spirit2")).setOption(option2, true);

}
